package com.jzsk.variable.center.zhengxin;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;


@Slf4j
@SpringBootApplication
@ComponentScan(value = {"com.jzsk.variable.center.dao", "com.jzsk.variable.center.zhengxin",
        "com.jzsk.variable.center.service"})
@MapperScan("com.jzsk.variable.center.dao.*.mapper")
public class ZhengXinApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(ZhengXinApplication.class, args);
        printStartInfo(application);
    }

    private static void printStartInfo(ConfigurableApplicationContext application) throws UnknownHostException {
        Environment env = application.getEnvironment();
        int availableProcessors = Runtime.getRuntime().availableProcessors();
        log.info("\n--------------------------------------------------------------------------------\n\t" +
                        "Application '{}' Server Application v1.0 is running! Access URLs:\n\t" +
                        "Local: \t\thttp://localhost:{}/\n\t" +
                        "External: \thttp://{}:{}/\n\t" +
                        "AvailableProcessors: \t{}\n\t" +
                        "docs: \t\t{}://{}/swagger-ui.html" +
                        "\n--------------------------------------------------------------------------------",
                env.getProperty("spring.application.name"),
                env.getProperty("server.port"),
                InetAddress.getLocalHost().getHostAddress(),
                env.getProperty("server.port"),
                availableProcessors,
                env.getProperty("swagger.protocol"),
                env.getProperty("swagger.host"));
    }

}
